<template>
  <div>
    <div class="add"  v-if="(rightValue & 1) > 0" @click="add">新增</div>
    <page-tab-list
      :url="url"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
    >
      <div v-if="this.active === 0">
        <van-cell class="card" v-for="(item, index) in list" :key="index">
           <van-tag
            v-if="item.IsRead === true"
            class="info_tag"
            color="#008000"
            >已读</van-tag>
          <van-tag v-if="item.IsRead != true" class="info_tag" type="warning"
            >未读</van-tag
          >
          <div class="warn_item">
            <div @click="viewDetail(item)">
              <van-row>
                <van-col span="24">
                  {{ index + 1 }}、{{ item.MeetingTitle }}</van-col
                >
              </van-row>
              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                 <img
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />会议时间：{{ item.MeetingDate | formatDateTime }}</van-col>
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                   <img
                    src="@/assets/Images/AppIcon/icon_list_area.png"
                    alt=""
                  />会议地点： {{ item.MeetingAddress }}
                </van-col>
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                 <img
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />会议主持： {{ item.MeetingHost }}
                  </van-col>
              </van-row>
              
            </div>
          </div>
        </van-cell>
      </div>
      <div v-if="this.active === 1">
        <van-cell v-for="(item, index) in list" :key="index" class="card">
          <div class="warn_item">
            <div @click="openDetail(item)">
              <van-row>
                <van-col span="24">
                  {{ index + 1 }}、{{ item.MeetingTitle }}</van-col
                >
              </van-row>
              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                 <img
                    src="@/assets/Images/AppIcon/icon_list_date.png"
                    alt=""
                  />会议时间：{{ item.MeetingDate | formatDateTime }}</van-col>
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                   <img
                    src="@/assets/Images/AppIcon/icon_list_area.png"
                    alt=""
                  />会议地点： {{ item.MeetingAddress }}
                </van-col>
              </van-row>

              <van-row gutter="20" class="dep_sort">
                <van-col span="24">
                 <img
                    src="@/assets/Images/AppIcon/icon_list_user.png"
                    alt=""
                  />会议主持： {{ item.MeetingHost }}
                  </van-col>
              </van-row>
            </div>
            <van-row v-show="item.PublishDate == null">
              <van-col span="24">
                <div class="dep_btm">
                  <div class="btm_item" @click="openEdit(item)">
                    <van-icon name="notes-o" size="18" />
                    <div class="mr-10">编辑</div>
                  </div>
                </div>
              </van-col>
            </van-row>
          </div>
        </van-cell>
      </div>
    </page-tab-list>
  </div>
</template>
<script>
import PageTabList from "@/components/PageTabList/PageTabList.vue";
import { getMenuByMenuCode } from "@/api/common";
export default {
  components: { PageTabList },
  data() {
    return {
      rightValue: 0,
      active: 0,
      url: this.$constUrl.CommonMeeting_GetPageData,
      list: [],
      params: [
        {
          title: "会议纪要",
          dataType: "Center",
        },
        {
          title: "我发布的",
          dataType: "List",
        },
      ],
    };
  },
  created() {
    this.getMenuByMenuCode();
  },
  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },
    viewDetail(item) {
      this.$router.push({
        path: "/CommonMeetingView",
        query: { id: item.ID },
      });
    },
    openDetail(item) {
      this.$router.push({
        path: "/CommonMeetingView",
        query: { id: item.ID },
      });
    },
    add() {
      this.$router.push({ path: "/CommonMeetingEdit" });
    },
    openEdit(item) {
      this.$router.push({
        path: "/CommonMeetingEdit",
        query: { id: item.ID },
      });
      return true;
    },
    delData(item) {
      this.$dialog
        .confirm({
          title: "询问",
          message: "您确定要删除该约谈记录吗？",
        })
        .then(() => {
          let params = { id: item.ID };
          this.$axios
            .get(this.$constUrl.CommonMeeting_Delete, {
              params: params,
            })
            .then((res) => {
              this.$toast("删除成功");
              this.$refs.PageTabList.refreshList();
            });
        })
    },
    getMenuByMenuCode() {
      var me = this;
      getMenuByMenuCode("CommonMeeting_List").then((res) => {
        me.rightValue = res.data ? res.data.RoleRightValue : 0;
      });
    },
  },
};
</script>

<style lang="less" scoped>
.all_dep {
  background-color: #ffffff;
}

.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;
  .warn_tag {
    position: absolute;
    right: 0;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}
.dep_sort {
  // display: flex;
  // flex-wrap: wrap;
  // margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}
</style>

